package org.supda.system.task;

import java.util.HashMap;
import java.util.List;

import org.apache.shiro.session.Session;
import org.supda.system.entity.TMessageSend;


/**
 * 
 * @author supda
 * @date 2017-3-11
 * 消息处理辅助类
 */
public final class MessageMapSingleton {
	
	//未读消息缓冲区
	private static HashMap<Long, List<TMessageSend>> messages = new HashMap<Long, List<TMessageSend>>();
	
	private static MessageMapSingleton messageMap;
	
	private MessageMapSingleton(){}
	
	//初始化实例
	public static  MessageMapSingleton getInstance(){
		
		if(messageMap == null){
			messageMap = new MessageMapSingleton();
		}
		return messageMap;
	}
	
	//获取指定session的消息列表
	public synchronized List<TMessageSend> getMessages(Long userId){
		return messages.get(userId);
	}
	
	//添加值
	public synchronized void setAttribute(Long userId, List<TMessageSend> messageList){
		messages.put(userId, messageList);
	}
}

